<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
//构造函数:主要功能初始化对象,可以想象成一套模板或一套方案;
//构造函数:通过new函数名来实现化对象的函数叫做构造函数;
//new就是在创建对象,从无到有,构造函数就是为初始化的对象添加属性和方法;
function ren(){
this.name=""; //this:表示现在还不知道,没有具体的名称;
this.sex="男";
this.age=40;
this.height=169;
}
var laoliu=new ren(); //通过new方法来创建具体的叫"laoliu"的人;
//通过new的方法创建具体的对象,this才有具体的名称,现在this就表示laoliu;
laoliu.name="老六";
laoliu["age"]=38;
laoliu.tuanyuan="共产党"
console.log(laoliu);
</script>
</head>
<body>
</body>
</html>